<?php
class Register extends Model
{
    /**
     *
     * @var Smarty
     */
    protected $_at;

    /**
     *
     * @return string
     */
    public function action()
    {
        $this->registerUser();
        return "start";
    }

    public function registerUser()
    {
        $name = $_POST['regName'];
        $pass = md5($_POST['regPass']);

        $verbindung = mysql_connect("localhost","root","");
        //or die ("Die Verbindung konnte nicht erstellt werden");
        mysql_select_db("game");
        $q = 'INSERT INTO Users SET password="' . $pass . '", name="' . $name . '"';
//        $this->getDb()->queryArray($q);
        mysql_query($q);
        mysql_close($verbindung);
    }

    /**
     * @return Smarty
     */
    public function getAt()
    {
        if (!$this->_at) {
            $this->_at = Controller::getActionTemplate();
        }
        return $this->_at;
    }

    /**
     *
     * @param Smarty $at 
     */
    public function setAt(Smarty $at) {
        $this->_at = $at;
    }
}

